package com.huawei.spare.part.replace.tftp;

import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

import static com.huawei.spare.part.replace.tftp.TFTPServer.ServerMode.GET_AND_PUT;

public class TFTPServerExample {

    public static void main(String[] args) throws IOException, InterruptedException {
        final File dir = new File("D:\\tftp");
        TFTPServer ts = new TFTPServer(dir, dir, GET_AND_PUT);
        ts.setSocketTimeout(5000);

        System.out.println("TFTP Server running.  Press enter to stop.");
        new InputStreamReader(System.in).read();
        ts.shutdown();
        System.out.println("Server shut down.");
        System.exit(0);

    }
}
